package com.moxie.ocr.ocr.idcard;

import android.content.Context;
import android.graphics.Rect;

import com.linkface.ocr.idcard.IDCard;
import com.linkface.ocr.idcard.LFIDCardScan;

public class MXIDCardScan {

    public static MXIDCardScan instance;

    private LFIDCardScan mIDCardScan;

    private Context mContext;

    public String getLicSDCardPath() {
        return mIDCardScan.getLicSDCardPath();
    }

    public String getLicAssetsName() {
        return mIDCardScan.getLicAssetsName();
    }

    private MXIDCardScan(Context context) {
        mContext = context;
        mIDCardScan = LFIDCardScan.getInstance();
    }

    public static MXIDCardScan getInstance(Context context) {
        if (instance == null) {
            Class var0 = MXIDCardScan.class;
            synchronized(MXIDCardScan.class) {
                if (instance == null) {
                    instance = new MXIDCardScan(context);
                }
            }
        }

        return instance;
    }


    public void initLicensePath(String licenseSDCardPathAndName, String licenseAssetsName) {
        mIDCardScan.initLicensePath(mContext,licenseSDCardPathAndName,licenseAssetsName);
    }

    public void initLicensePath(String licenseAssetsName) {
        mIDCardScan.initLicensePath(mContext, "", licenseAssetsName);
    }


    public boolean initIDCardScan() throws Exception {
        return mIDCardScan.initIDCardScan(mContext);
    }

    public boolean initIDCardScan( String licenseName) throws Exception {
        return mIDCardScan.initIDCardScan(mContext,licenseName);
    }

    public boolean checkLicenseValid() {
        return mIDCardScan.checkLicenseValid(mContext);
    }

    public int getRemainingDays() {
        return mIDCardScan.getRemainingDays(mContext);
    }

    public String getLicenseTime() {
        return mIDCardScan.getLicenseTime(mContext);
    }


    public static byte[] cv_finance_wrapper_get_license_time(String var0) throws Exception{
        return LFIDCardScan.cv_finance_wrapper_get_license_time(var0);
    }


    public static void releaseIDCardScan() {
        LFIDCardScan.releaseIDCardScan();
    }


    public static com.moxie.ocr.ocr.idcard.MXOCRResult scanIDCard(int side, byte[] bitmap, int width, int height, Rect viewfinderRect, int infoRequiredMask, boolean isFirstRecognize, boolean isInFrame) {
        com.moxie.ocr.ocr.idcard.MXOCRResult mIDCard = null;
        IDCard card= LFIDCardScan.scanIDCard(side,bitmap,width,height,viewfinderRect,infoRequiredMask,isFirstRecognize,isInFrame);
        if (card != null){
            mIDCard=new com.moxie.ocr.ocr.idcard.MXOCRResult(card.getCardResult(),card.getSide());
            mIDCard.setRectifiedImage(card.getRectifiedImage());
        }
        return mIDCard;
    }


    public static byte[] clipNv21Byte(byte[] var0, Rect var1, int var2, int var3){
        return LFIDCardScan.clipNv21Byte(var0,var1,var2,var3);
    }

}
